<html>
<head><meta charset="utf-8"><title>array split APIs #74674 · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html">array split APIs #74674</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204786856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204786856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204786856">(Jul 23 2020 at 11:58)</a>:</h4>
<p>To continue hashing out what we could possibly add to nightly std using zulip instead of github</p>



<a name="204786881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204786881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204786881">(Jul 23 2020 at 11:58)</a>:</h4>
<p>I think it would be best to start with the slice split with only the first half of the split having a constant size, since we can support that API correctly today</p>



<a name="204786948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204786948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204786948">(Jul 23 2020 at 11:59)</a>:</h4>
<p>However, we need a good name for it that doesn't ultimately conflict with the array version that splits into two arrays</p>



<a name="204792863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204792863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204792863">(Jul 23 2020 at 12:58)</a>:</h4>
<p>Would it be plausible to add the two-generic version (<code>fn split_array&lt;const N: usize, const M: usize&gt;(&amp;self) -&gt; (&amp;[T; N], &amp;[T; M])</code>) now, and then at some point in the future make <code>M</code> a default parameter (once we can support those with the value being <code>LENGTH - N</code>? That way it'll become just as usable as a single-parameter function and essentially just as fast I think, right?</p>



<a name="204793333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204793333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204793333">(Jul 23 2020 at 13:01)</a>:</h4>
<p>I think we should be able to write const wf bounds on nightly before we stabilize <code>min_const_generics</code>, at which point <code>N - M</code> becomes possible to use</p>



<a name="204793481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204793481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204793481">(Jul 23 2020 at 13:02)</a>:</h4>
<p>so while these bounds probably can't be written on stable itself, they should already work inside of std</p>



<a name="204794064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204794064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204794064">(Jul 23 2020 at 13:06)</a>:</h4>
<p>or wait, that still means that <code>N - M</code> will be user facing though, so I don't think we should stabilize that... rn</p>



<a name="204794723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204794723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204794723">(Jul 23 2020 at 13:12)</a>:</h4>
<blockquote>
<p>I think we should be able to write const wf bounds on nightly before we stabilize min_const_generics, at which point N - M becomes possible to use</p>
</blockquote>
<p>This mostly applies to restricting <code>array_chunks</code> and friends to <code>N &gt; 0</code> and I think that is something we should do</p>



<a name="204800705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204800705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204800705">(Jul 23 2020 at 14:01)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> we haven't made any progress on function default parameters ever so who knows when that would be</p>



<a name="204800786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204800786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204800786">(Jul 23 2020 at 14:02)</a>:</h4>
<p>that's true :/</p>



<a name="204807168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204807168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204807168">(Jul 23 2020 at 14:48)</a>:</h4>
<p>I thought we had defaults for function <em>type</em> parameters and that led me down a rabbit hole to <a href="https://github.com/rust-lang/rust/issues/36887#issuecomment-342667728">https://github.com/rust-lang/rust/issues/36887#issuecomment-342667728</a></p>



<a name="204807231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/array%20split%20APIs%20%2374674/near/204807231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/array.20split.20APIs.20.2374674.html#204807231">(Jul 23 2020 at 14:49)</a>:</h4>
<p>so I guess that needs to be worked out before we can have <code>const M: usize = LENGTH - N</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>